
package com.multimedia.room;

import com.multimedia.room.media.AudioPlayerManager;
import com.multimedia.room.R;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;
import android.widget.MediaController.MediaPlayerControl;

public class BaseService extends Service implements MediaPlayer.OnErrorListener {
	private static final String TAG="BaseService";

	  MediaPlayer player; 
    @Override
    public IBinder onBind(Intent arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void onCreate() {
    	Log.d(TAG, "onCreate");
        super.onCreate();
    }

    @Override
    public void onDestroy() {
    	if(player!=null){
    	player.stop();
    	player.release();
    	player=null;
    	}
    	Log.d(TAG, "onDestroy");
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
//    	if(player==null){
//    			player = MediaPlayer.create(this, R.raw.mute);
//    			player.setLooping(true);
//
//		}
//    	player.setOnErrorListener(this);
//    	new Thread(new Runnable() {
//
//			@Override
//			public void run() {
//				player.start();
//
//			}
//		}).start();
    	Log.d(TAG, "onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public boolean onUnbind(Intent intent) {
        // TODO Auto-generated method stub
        return super.onUnbind(intent);
    }


	//@Override
	public boolean onError(MediaPlayer mp, int what, int extra) {
		// TODO Auto-generated method stub
		return false;
	}

}
